#pragma once

#include <D3D11.h>
#include <D3DX10math.h>
#include <fstream>
using namespace std;

#include "textureclass.h"

/// <Summary>
/// FontClass: Stores the font characters and texture. Includes method for building a
/// vertex array for a sentence storing the position and texture coordinates.
/// </Summary>

class FontClass
{
private:
	struct FontType				// Structure for each character in font.
	{
		float left, right;		// Left and right TU coordinates for character.
		int	  size;				// Width of the character in pixels.
	};

	struct VertexType			// Vertex type for vertex buffer.
	{
		D3DXVECTOR3 position;	// Vertex position.
		D3DXVECTOR2 texture;	// Vertex texture coordinate.
	};

public:
	FontClass();
	FontClass(const FontClass&);
	~FontClass();

	bool Initialize(ID3D11Device* device, char* fontFilename, WCHAR* textureFilename);
	void Shutdown();

	ID3D11ShaderResourceView* GetTexture();
	void BuildVertexArray(void* vertices, char* sentenceText, float drawX, float drawY);

private:
	bool LoadFontData(char* filename);
	void ReleaseFontData();
	bool LoadTexture(ID3D11Device* device, WCHAR* filename);
	void ReleaseTexture();

private:
	FontType*	  m_Font;			// Array of all the font characters in the text file.
	TextureClass* m_Texture;		// Font texture DDS.
};